package com.ljs.vuetest.controller;

import com.ljs.vuetest.config.TokenUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class Mymusic {
    @RequestMapping("/mymusic")//访问axios页面
    public  String music(HttpServletRequest request, Model model){
        String token = request.getHeader("token");// 从 http 请求头中取出 token
        System.out.println("token"+token);
        String username= TokenUtils.getUsername(token);//根据token来获取用户名
        System.out.println("用户名是"+username);
        model.addAttribute("username",username);
        return  "mymusic";
    }
}
